home *** CD-ROM | disk | FTP | other *** search
/ Linux 68k 2000 / Linux 68k 2000.iso / dokus / Glibc2-HOWTO < prev    next >
Encoding:
Text File  |  1997-12-21  |  34.0 KB  |  898 lines

  1.   Glibc 2 HOWTO
  2.   Eric Green, thrytis@imaxx.net
  3.   v1.3, 9 December 1997
  4.  
  5.   The glibc 2 HOWTO covers installing and using the GNU C Library ver¡
  6.   sion 2 (libc 6) on Linux systems.
  7.  
  8.   1.  Introduction.
  9.  
  10.   1.1.  About glibc 2.
  11.  
  12.   Glibc 2 is the latest version of the GNU C Library. It currently runs
  13.   unmodified on GNU Hurd systems and Linux i386, m68k, and alpha
  14.   systems.  Ports to Linux PowerPC, MIPS, and Sparc are actively being
  15.   developed.  In the future support for other architectures and
  16.   operating systems will be added.
  17.  
  18.   On Linux, glibc 2 is used as the libc with major version 6, the
  19.   successor of the Linux libc 5.  It is intended by the Linux libc
  20.   developers to eventually replace libc 5.  It is currently
  21.   experimental, but is stable enough to be used by people interested in
  22.   testing it and willing to put a little extra effort to get things
  23.   working.  The latest version is actually quite stable if the program
  24.   you are using supports it.  Version 2.1 (due out in the near future)
  25.   will be ready for main stream use.
  26.  
  27.   There are three optional add-ons available for glibc 2:
  28.  
  29.      Crypt
  30.         The UFC-crypt package.  It is seperate  because of export
  31.         restrictions.
  32.  
  33.      LinuxThreads
  34.         An implementation of the Posix 1003.1c "pthread" interface.
  35.  
  36.      Locale data
  37.         Contains the data needed to build the locale data files to use
  38.         the internationalization features of the glibc.
  39.  
  40.   The crypt and LinuxThreads add-ons are strongly recommended... not
  41.   using them risks to be incompatible with the libraries of other
  42.   systems.  (If you do not wish to use them, you must add the option
  43.   --disable-sanity-checks when you run configure.)
  44.  
  45.   1.2.  About this document.
  46.  
  47.   This HOWTO covers installing the glibc 2 library on an existing Linux
  48.   system.  It is tailored for users of Intel based systems currently
  49.   using libc 5, but users of other systems and alternate libraries (such
  50.   as glibc 1) should be able to use this information by substituting the
  51.   proper filenames and architecture names in the appropriate places.
  52.  
  53.   The latest copy of this HOWTO can be found as part of the Linux
  54.   Documentation Project <http://sunsite.unc.edu/LDP> or from
  55.   <http://www.imaxx.net/~thrytis/glibc/Glibc2-HOWTO.html>.
  56.  
  57.   1.3.  Recent changes in this document.
  58.  
  59.   Differences between version 1.3 and 1.2:
  60.  
  61.   ╖  Added a note about recommended add-ons.
  62.  
  63.   ╖  Added information about the glibc-linux mailing list.
  64.  
  65.   ╖  Updated information on Redhat glibc based distribution.
  66.  
  67.   ╖  Updated location of Debian glibc packages.
  68.  
  69.   ╖  Added texinfo version dependancy.
  70.  
  71.   Differences between version 1.1 and 1.2:
  72.  
  73.   ╖  Added some information to the Reporting bugs section, and updated
  74.      bug reporting email and gnats addresses. (Changes by Andreas
  75.      Jaeger)
  76.  
  77.   ╖  Updated Credits section.
  78.  
  79.   2.  Choosing your installation method.
  80.  
  81.   There are a few ways to install glibc.  You can install the libraries
  82.   as a test, using the existing libraries as the default but letting you
  83.   try the new libraries by using different options when compiling your
  84.   program.  Installing in this way also makes it easy to remove glibc in
  85.   the future (though any program linked with glibc will no longer work
  86.   after the libraries are removed). Using glibc as a test library
  87.   requires you to compile the libraries from source.  There is no binary
  88.   distribution for installing libraries this way.  This installation is
  89.   described in ``Installing as a test library''.
  90.  
  91.   The other way described in this document to install is using glibc as
  92.   your primary library.  All new programs that you compile on your
  93.   system will use glibc, though you can link programs with your old
  94.   libraries using different options while compiling.  You can either
  95.   install the libraries from binaries, or compile the library yourself.
  96.   If you want to change optimization or configuration options, or use an
  97.   add-on which is not distributed as a binary package, you must get the
  98.   source distribution and compile.  This installation procedure is
  99.   described in ``Installing as the primary C library''.
  100.  
  101.   Frodo Looijaard describes yet another way of installing glibc.  His
  102.   method involves installing glibc as a secondary library and setting up
  103.   a cross compiler to compile using glibc.  The installation procedure
  104.   for this method is more complicated then the test library install
  105.   described in this document, but allows for easier compiling when
  106.   linking to glibc.  This method is described in his Installing glibc-2
  107.   on Linux <http://huizen.dds.nl/~frodol/glibc/> document.
  108.  
  109.   If you are currently running Debian 1.3 but do not want to upgrade to
  110.   the unstable version of Debian to use glibc, the Debian libc5 to libc6
  111.   Mini-HOWTO <http://www.gate.net/~storm/FAQ/libc5-libc6-Mini-
  112.   HOWTO.html> describes how to use Debian packages to upgrade your
  113.   system.
  114.  
  115.   If you are installing glibc 2 on an important system, you should not
  116.   install it as your primary library.  Use the test install, or better,
  117.   try it on a spare system.  Even if there are no bugs, some programs
  118.   will need to be modified before they will compile due to changes in
  119.   function prototypes and types.
  120.  
  121.   3.  Getting the library.
  122.  
  123.   The glibc 2 consists of the glibc package and three optional add-on
  124.   packages, LinuxThreads, Locale, and Crypt.  The source can be found at
  125.  
  126.   ╖  <ftp://prep.ai.mit.edu/pub/gnu/glibc-2.0.5.tar.gz>
  127.  
  128.   ╖  <ftp://prep.ai.mit.edu/pub/gnu/glibc-linuxthreads-2.0.5.tar.gz>
  129.  
  130.   ╖  <ftp://prep.ai.mit.edu/pub/gnu/glibc-localedata-2.0.5.tar.gz>
  131.  
  132.   ╖  <ftp://prep.ai.mit.edu/pub/gnu/glibc-crypt-2.0.5.tar.gz>
  133.  
  134.   Version 2.0.5c requires an additional patch, which can be found at
  135.   <ftp://prep.ai.mit.edu/pub/gnu/glibc-2.0.5-2.0.5c.diff.gz>.
  136.  
  137.   It will take about 150 MB of disk space for the full compile and
  138.   install.  The basic binary install of just the core library package is
  139.   about 50 MB.
  140.  
  141.   Binary packages for 2.0.5c are not available.  Version 2.0.4 binary
  142.   packages are available for i386 and m68k, and version 2.0.1 for the
  143.   alpha can be found at
  144.  
  145.   ╖  Intel x86:
  146.  
  147.   ╖  <ftp://prep.ai.mit.edu/pub/gnu/glibc-2.0.4.bin.i386.tar.gz>
  148.  
  149.   ╖  <ftp://prep.ai.mit.edu/pub/gnu/glibc-crypt-2.0.4.bin.i386.tar.gz>
  150.  
  151.   ╖  Alpha:
  152.  
  153.   ╖  <ftp://prep.ai.mit.edu/pub/gnu/glibc-2.0.1.bin.alpha-linux.tar.gz>
  154.  
  155.   ╖  <ftp://prep.ai.mit.edu/pub/gnu/glibc-crypt-2.0.1.bin.alpha-
  156.      linux.tar.gz>
  157.  
  158.   ╖  m68k:
  159.  
  160.   ╖  <ftp://prep.ai.mit.edu/pub/gnu/glibc-2.0.4-m68k-linux.bin.tar.gz>
  161.  
  162.   ╖  <ftp://prep.ai.mit.edu/pub/gnu/glibc-crypt-2.0.4-m68k-
  163.      linux.bin.tar.gz>
  164.  
  165.      There are export restrictions on the crypt add-on.  Non-US users
  166.      should get it from  <ftp://ftp.ifi.uio.no/pub/gnu>.
  167.  
  168.   If you are running a Red Hat distribution, you can get rpms for glibc
  169.   2 from <ftp://ftp.redhat.com/pub/redhat/>.  Glibc 2 is the primary C
  170.   library for the new Red Hat distribution 5.0.
  171.  
  172.   If you are running a Debian distribution, you can get the packages for
  173.   glibc 2 from  <ftp://ftp.debian.org/debian/dists/unstable/main/>.  The
  174.   files are named libc6.  Glibc 2 is now part of the base package of the
  175.   hamm version of Debian, and will be the primary libc when Debian 2.0
  176.   is released.
  177.  
  178.   4.  Installing as a test library.
  179.  
  180.   This section covers installing glibc 2 as a test library.  Anything
  181.   you compile will be linked to your existing libraries unless you give
  182.   some extra parameters to link to the new libraries.  It appears that
  183.   the paths are compiled into quite a few files, so you probably have to
  184.   install the library from source.
  185.  
  186.   4.1.  Compiling and installing.
  187.  
  188.   4.1.1.  Prerequisites.
  189.  
  190.   ╖  About 150 MB free disk space
  191.  
  192.   ╖  GNU make 3.75
  193.  
  194.   ╖  gcc >= 2.7.2 (better 2.7.2.1)
  195.  
  196.   ╖  binutils 2.8.1 (for alpha you need a snapshot)
  197.  
  198.   ╖  bash 2.0
  199.  
  200.   ╖  autoconf 2.12 (if you change configure.in)
  201.  
  202.   ╖  texinfo 3.11
  203.  
  204.   On an i586@133 with 64 MB of RAM, it takes about 3 hours to compile
  205.   with full libraries with add-ons.  On a loaded i686@200, it takes
  206.   about half an hour.
  207.  
  208.   4.1.2.  Extracting the source.
  209.  
  210.   You need to extract the source from the archives so you can compile
  211.   it.  The best way to do this is:
  212.  
  213.         tar xzf glibc-2.0.5.tar.gz
  214.         cd glibc-2.0.5
  215.         cat ../glibc-2.0.5-2.0.5c.diff.gz | gzip -d | patch -p0
  216.         tar xzf ../glibc-linuxthreads-2.0.5.tar.gz
  217.         tar xzf ../glibc-crypt-2.0.5.tar.gz
  218.         tar xzf ../glibc-localedata-2.0.5.tar.gz
  219.  
  220.   This will put linuxthreads, crypt, and localedata directories in the
  221.   glibc-2.0.5 directory where configure can find these add-ons.
  222.  
  223.   4.1.3.  Configuring.
  224.  
  225.   In the glibc-2.0.5 directory, create a directory named compile, and cd
  226.   into it.  All work will be done in this directory, which will simplify
  227.   cleaning up.  (The developers have not been very concerned with
  228.   getting 'make clean' perfect yet.)
  229.  
  230.         mkdir compile
  231.         cd compile
  232.  
  233.   Run ../configure.  To use the add-on packages, you need to specify
  234.   them with --enable-add-ons, such as --enable-add-
  235.   ons=linuxthreads,crypt,localedata.  You also need to choose a destina¡
  236.   tion directory to install to.  /usr/i486-linuxglibc2 is a good choice.
  237.   The configure line for this would be:
  238.  
  239.         ../configure --enable-add-ons=linuxthreads,crypt,localedata --prefix=/usr/i486-linuxglibc2
  240.  
  241.   4.1.4.  Compiling and installing.
  242.  
  243.   To compile and verify, run:
  244.  
  245.         make
  246.         make check
  247.  
  248.   If the 'make check' succeeds, install the library:
  249.  
  250.         make install
  251.  
  252.   4.2.  Updating the dynamic loader.
  253.  
  254.   1. Create a link from the new ld.so to /lib/ld-linux.so.2:
  255.  
  256.         ln -s /usr/i486-linuxglibc2/lib/ld-linux.so.2 /lib/ld-linux.so.2
  257.  
  258.   This is the only library where the location is fixed once a program is
  259.   linked, and using a link in /lib will ease upgrading to glibc as your
  260.   primary C library when the stable version is released.
  261.  
  262.   2. Edit /etc/ld.so.conf.  You need to add path to the lib directory
  263.      the new libraries reside in at the end of the file, which will be
  264.      <prefix>/lib, such as /usr/i486-linuxglibc2/lib for the choice
  265.      above.  After you have modified /etc/ld.so.conf, run
  266.  
  267.         ldconfig -v
  268.  
  269.   4.3.  Configuring for gcc.
  270.  
  271.   The last step of installation is updating /usr/lib/gcc-lib so gcc
  272.   knows how to use the new libraries.  First you need to duplicate the
  273.   existing configuration.  To find out which configuration is current,
  274.   use the -v option of gcc:
  275.  
  276.         % gcc -v
  277.         Reading specs from /usr/lib/gcc-lib/i486-unknown-linux/2.7.2.2/specs
  278.         gcc version 2.7.2.2
  279.  
  280.   In this case, i486-unknown-linux is the system, and 2.7.2.2 is the
  281.   version.  You need to copy the /usr/lib/gcc-lib/<system> to the new
  282.   test system directory:
  283.  
  284.         cd /usr/lib/gcc-lib/
  285.         cp -r i486-unknown-linux i486-linuxglibc2
  286.  
  287.   Change into your new test system directory and version directory
  288.  
  289.         cd /usr/lib/gcc-lib/i486-linuxglibc2/2.7.2.2
  290.  
  291.   and edit the file specs found in this directory.  In this file, change
  292.   /lib/ld-linux.so.1 to /lib/ld-linux.so.2.  You also need to remove all
  293.   expressions %{...:-lgmon} in the file, since glibc does not use the
  294.   gmon library for profiling.  A sample specs file can be found in the
  295.   ``Sample specs file'' section.
  296.  
  297.   4.4.  Updating header file links.
  298.  
  299.   You need create links in your new include directory to other include
  300.   directories:
  301.  
  302.         cd /usr/i486-linuxglibc2/include
  303.         ln -s /usr/src/linux/include/linux
  304.         ln -s /usr/src/linux/include/asm
  305.         ln -s /usr/X11R6/include/X11
  306.  
  307.   You might also have other libraries such as ncurses which need their
  308.   header files put in this directory.  You should copy or link the files
  309.   from /usr/include.  (Some libraries may need to be recompiled with
  310.   glibc2 in order to work with it.  In these cases, just compile and
  311.   install the package to /usr/i486-linuxglibc2.)
  312.  
  313.   4.5.  Testing your installation.
  314.  
  315.   To test the installation, create the following program in a file
  316.   glibc.c:
  317.  
  318.         #include <stdio.h>
  319.  
  320.         main()
  321.         {
  322.             printf("hello world!\n");
  323.         }
  324.  
  325.   and compile with the options of "-b <base install directory> -nostdinc
  326.   -I<install directory>/include -I/usr/lib/gcc-lib/<new system dir>/<gcc
  327.   version>/include":
  328.  
  329.         % gcc -b i486-linuxglibc2 -nostdinc -I/usr/i486-linuxglibc2/include -I/usr/lib/gcc-lib/i486-linuxglibc2/2.7.2.2/include glibc.c -o glibc
  330.  
  331.   Use ldd to verify the program was linked with glibc2, and not your old
  332.   libc:
  333.  
  334.         % ldd glibc
  335.         libc.so.6 => /usr/i486-linuxglibc2/lib/libc-2.0.5.so (0x4000d000)
  336.         /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
  337.  
  338.   If it compiles, the links check out, and it generates "hello world!"
  339.   when run, the installation succeeded.
  340.  
  341.   5.  Installing as the primary C library.
  342.  
  343.   This section covers installing glibc 2 as your primary C library.  Any
  344.   new programs you compile will be linked with this library, unless you
  345.   use special compile options to link with another version.
  346.  
  347.   If you are are using Redhat or Debian and have downloaded the
  348.   appropriate rpm or deb files, see the Redhat or Debian installion
  349.   instructions.  You can then skip this section.
  350.  
  351.   5.1.  Building the library from source.
  352.  
  353.   This section explains how to compile glibc 2 and add-ons from the
  354.   sources.  You must compile the library if you want to change
  355.   optimization or configuration options or use a package you do not have
  356.   the binaries for.
  357.  
  358.   5.1.1.  Prerequisites.
  359.  
  360.   ╖  About 150 MB free disk space
  361.  
  362.   ╖  GNU make 3.75
  363.  
  364.   ╖  gcc >= 2.7.2 (better 2.7.2.1)
  365.  
  366.   ╖  binutils 2.8.1 (for alpha you need a snapshot)
  367.  
  368.   ╖  bash 2.0
  369.  
  370.   ╖  autoconf 2.12 (if you change configure.in)
  371.  
  372.   ╖  texinfo 3.11
  373.  
  374.   On an i586@133 with 64 MB of RAM, it takes about 3 hours to compile
  375.   with full libraries with add-ons.  On a loaded i686@200, it takes
  376.   about half an hour.
  377.  
  378.   5.1.2.  Extracting the source.
  379.  
  380.   You need to extract the source from the archives so you can compile
  381.   it.  The best way to do this is:
  382.  
  383.         tar xzf glibc-2.0.5.tar.gz
  384.         cd glibc-2.0.5
  385.         cat ../glibc-2.0.5-2.0.5c.diff.gz | gzip -d | patch -p0
  386.         tar xzf ../glibc-linuxthreads-2.0.5.tar.gz
  387.         tar xzf ../glibc-crypt-2.0.5.tar.gz
  388.         tar xzf ../glibc-localedata-2.0.5.tar.gz
  389.  
  390.   This will put linuxthreads, crypt, and localedata directories in the
  391.   glibc-2.0.5 directory where configure can find these add-ons.
  392.  
  393.   5.1.3.  Configuring.
  394.  
  395.   In the glibc-2.0.5 directory, create a directory named compile, and cd
  396.   into it.  All work will be done in this directory, which will simplify
  397.   cleaning up.  (The developers have not been very concerned with
  398.   getting 'make clean' perfect yet.)
  399.  
  400.        mkdir compile
  401.        cd compile
  402.  
  403.   Run ../configure.  To use the add-on packages, you need to specify
  404.   them with --enable-add-ons, such as --enable-add-
  405.   ons=linuxthreads,crypt,localedata.  You probably will also want to
  406.   specify paths where it will be installed.  To match the standard linux
  407.   distributions, specify --prefix=/usr.  (When a prefix of /usr is spec¡
  408.   ified on a linux system, configure knows to adjust other paths to
  409.   place libc.so and other important libraries in /lib.)  The whole con¡
  410.   figure line would be:
  411.  
  412.         ../configure --enable-add-ons=linuxthreads,crypt,localedata --prefix=/usr
  413.  
  414.   5.1.4.  Compiling.
  415.  
  416.   To compile and verify, run:
  417.  
  418.         make
  419.         make check
  420.  
  421.   5.2.  Preparing for installation.
  422.  
  423.   Now you need to move some files around to prepare for the new library,
  424.   whether you are installing from source or binaries.  Any new program
  425.   compiled will be linked to glibc, but old programs which are not
  426.   statically linked will still depend on libc 5, so you can not just
  427.   overwrite the old version.
  428.  
  429.   1. Create a new directory to hold the old files to:
  430.  
  431.         mkdir -p /usr/i486-linuxlibc5/lib
  432.  
  433.   2. The old header files must be evacuated from /usr/include:
  434.  
  435.         mv /usr/include /usr/i486-linuxlibc5/include
  436.  
  437.   3. Create a new include directory and set up the links to other
  438.      include directories:
  439.  
  440.    mkdir /usr/include
  441.  
  442.    ln -s /usr/src/linux/include/linux /usr/include/linux
  443.    ln -s /usr/src/linux/include/asm /usr/include/asm
  444.    ln -s /usr/X11R6/include/X11 /usr/include/X11
  445.    ln -s /usr/lib/g++-include /usr/include/g++
  446.  
  447.   The links may need adjusting according to your distribution.  At least
  448.   Slackware puts g++ headers in /usr/local/g++-include, while Debian
  449.   puts the headers in /usr/include/g++, and links /usr/lib/g++-include
  450.   to /usr/include/g++.  In the later case, you probably will want to
  451.   move the original g++ include directory back to /usr/include.
  452.  
  453.   4. Restore any extra header files and links.  Some non-standard
  454.      libraries such as ncurses put files in /usr/include or put a link
  455.      to their include directories in the /usr/include.  These files and
  456.      links need to be restored in order to use the extra libraries
  457.      properly.
  458.  
  459.   5. Add your new library directory (such as /usr/i486-linuxlibc5/lib)
  460.      at the top of your /etc/ld.so.conf file.  You should have ld.so
  461.      1.8.8 or better installed to avoid getting strange messages once
  462.      glibc is installed.
  463.  
  464.   6. Move/copy all the old C libraries into the new directory.
  465.  
  466.         mv /usr/lib/libbsd.a /usr/i486-linuxlibc5/lib
  467.         mv /usr/lib/libc.a /usr/i486-linuxlibc5/lib
  468.         mv /usr/lib/libgmon.a /usr/i486-linuxlibc5/lib
  469.         mv /usr/lib/libm.a /usr/i486-linuxlibc5/lib
  470.         mv /usr/lib/libmcheck.a /usr/i486-linuxlibc5/lib
  471.         mv /usr/lib/libc.so /usr/i486-linuxlibc5/lib
  472.         mv /usr/lib/libm.so /usr/i486-linuxlibc5/lib
  473.         cp /lib/libm.so.5.* /usr/i486-linuxlibc5/lib
  474.         cp /lib/libc.so.5.* /usr/i486-linuxlibc5/lib
  475.  
  476.   libm.so.5 and libc.so.5 should be copied and not moved if /usr is a
  477.   seperate partition from /, because they are required by programs used
  478.   to start linux and must be located on the root drive partition.
  479.  
  480.   7. Move the /usr/lib/*.o files into the new directory.
  481.  
  482.         mv /usr/lib/crt1.o /usr/i486-linuxlibc5/lib
  483.         mv /usr/lib/crti.o /usr/i486-linuxlibc5/lib
  484.         mv /usr/lib/crtn.o /usr/i486-linuxlibc5/lib
  485.         mv /usr/lib/gcrt1.o /usr/i486-linuxlibc5/lib
  486.  
  487.   8. Update your library cache after your libraries are moved.
  488.  
  489.    ldconfig -v
  490.  
  491.   5.3.  Installing from the binary package.
  492.  
  493.   If you are installing glibc from precompiled binaries, you must:
  494.  
  495.         cd /
  496.         gzip -dc glibc-2.0.bin.i386.tar.gz | tar tvvf -
  497.         gzip -dc glibc-crypt-2.0.bin.i386.tar.gz | tar tvvf -
  498.         ldconfig -v
  499.  
  500.   If you have a different architecture or version, substitute the proper
  501.   file names.
  502.  
  503.   5.4.  Installing from the source.
  504.  
  505.   To install the library from source, run:
  506.  
  507.         make install
  508.         ldconfig -v
  509.  
  510.   5.5.  Updating the gcc specs.
  511.  
  512.   The final step of the installation (for both binary and source
  513.   installs) is to update the gcc specs file so you can link your
  514.   programs properly. To determine which specs file is the one used by
  515.   gcc, use:
  516.  
  517.         % gcc -v
  518.         reading specs from /usr/lib/gcc-lib/i486-unknown-linux/2.7.2.2/specs
  519.         gcc version 2.7.2.2
  520.  
  521.   In this case, i486-unknown-linux is the system, and 2.7.2.2 is the
  522.   version.  You need to copy the /usr/lib/gcc-lib/<system> to the old
  523.   system directory:
  524.  
  525.    cd /usr/lib/gcc-lib/
  526.    cp -r i486-unknown-linux i486-linuxlibc5
  527.  
  528.   Change into the original directory and version directory
  529.  
  530.         cd /usr/lib/gcc-lib/i486-unknown-linux/2.7.2.2
  531.  
  532.   and edit the file specs found in this directory.  In this file, change
  533.   /lib/ld-linux.so.1 to /lib/ld-linux.so.2.  You also need to remove all
  534.   expressions %{...:-lgmon} in the file, since glibc does not use the
  535.   gmon library for profiling.  A sample specs file can be found in the
  536.   ``Sample specs file'' section.
  537.  
  538.   5.6.  Testing your installation.
  539.  
  540.   To test the installation, create the following program in a file
  541.   glibc.c:
  542.  
  543.         #include <stdio.h>
  544.  
  545.         main()
  546.         {
  547.             printf("hello world!\n");
  548.         }
  549.  
  550.   and compile the program.
  551.  
  552.         % gcc glibc.c -o glibc
  553.  
  554.   Use ldd to verify the program was linked with glibc2, and not your old
  555.   libc:
  556.  
  557.         % ldd glibc
  558.         libc.so.6 => /lib/libc.so.6 (0x4000e000)
  559.         /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
  560.  
  561.   If this compiles and generates "hello world!" when run, the installa¡
  562.   tion was successful.
  563.  
  564.   6.  Compiling with the non-primary libc.
  565.  
  566.   There are times you will want to use an alternate library to compile
  567.   your programs with.  This section explains how to accomplish this,
  568.   using the directories and installation names used in the examples in
  569.   the previous two sections.  Remember to change the names to fit your
  570.   setup.
  571.  
  572.   6.1.  A warning when using non-primary libcs.
  573.  
  574.   Before compiling any programs which is used in the system boot
  575.   process, remember that if the program is dynamically linked and is
  576.   used before the non-root partitions are mounted, all linked libraries
  577.   must be on the root partition.  Following the installation process in
  578.   the previous section for installing glibc as your primary C library,
  579.   the old libc is left in /lib, which will be on your root partition.
  580.   This means all of your programs will still work during booting.
  581.   However, if /usr is on a different partition and you install glibc as
  582.   a test library in /usr/i486-linuxglibc2, any new programs you compile
  583.   with glibc will not work until your /usr partition is mounted.
  584.  
  585.   6.2.  Compiling programs with a test glibc.
  586.  
  587.   To compile a program with a test-install glibc, you need to reset the
  588.   include paths to point to the glibc includes.  Specifying "-nostdinc"
  589.   will negate the normal paths, and "-I/usr/i486-linuxglibc2/include"
  590.   will point to the glibc includes.  You will also need to specify the
  591.   gcc includes, which are found in /usr/lib/gcc-
  592.   lib/i486-linuxglibc2/2.7.2.2/include (assuming you installed the test
  593.   lib in i486-linuxglibc2 with gcc version 2.7.2.2).
  594.  
  595.   To link a program with a test-install glibc, you need to specify the
  596.   gcc setup.  This is done by using the option "-b i486-linuxglibc2".
  597.  
  598.   For most programs, you can specify these new options by adding them to
  599.   the $CFLAGS and $LDFLAGS makefile options:
  600.  
  601.         CFLAGS = -nostdinc -I/usr/i486-linuxglibc2/include -I/usr/lib/gcc-lib/i486-linuxglibc2/2.7.2.2/include -b i486-linuxglibc2
  602.         LDFLAGS = -b i486-linuxglibc2
  603.  
  604.   If you are using a configure script, define the $CFLAGS and $LDFLAGS
  605.   shell variables (by using env/setenv for csh/tcsh, or set/export for
  606.   sh/bash/etc) before running configure.  The makefiles generated by
  607.   this should contain the proper $CFLAGS and $LDFLAGS.  Not all config¡
  608.   ure scripts will pick up the variables, so you should check after run¡
  609.   ning configure and edit the makefiles by hand if necessary.
  610.  
  611.   If the programs you are compiling only call gcc (and not cpp or
  612.   binutils directly), you can use the following script to save having to
  613.   specify all of the options each time:
  614.  
  615.         #!/bin/bash
  616.         /usr/bin/gcc -b i486-linuxglibc2 -nostdinc \
  617.                      -I/usr/i486-linuxglibc2/include \
  618.                      -I/usr/lib/gcc-lib/i486-linuxglibc2/2.7.2.2/include "$@"
  619.  
  620.   You can then use this script instead of "gcc" when compiling.
  621.  
  622.   6.3.  Compiling programs with libc 5 when glibc is primary library.
  623.  
  624.   To compile a program with your old libraries when you have installed
  625.   glibc as your main library, you need to reset the include paths to the
  626.   old includes.  Specifying "-nostdinc" will negate the normal paths,
  627.   and "-I/usr/i486-linuxlibc5/include" will point to the glibc includes.
  628.   You must also specify "-I/usr/lib/gcc-
  629.   lib/i486-linuxlibc5/2.7.2.2/include" to include the gcc specific
  630.   includes.  Remember to adjust these paths based on the what you named
  631.   the new directories and your gcc version.
  632.  
  633.   To link a program with your old libc, you need to specify the gcc
  634.   setup.  This is done by using the option "-b i486-linuxlibc5".
  635.  
  636.   For most programs, you can specify these new options by appending them
  637.   to the $CFLAGS and $LDFLAGS makefile options:
  638.  
  639.         CFLAGS = -nostdinc -I/usr/i486-linuxlibc5/include -I/usr/lib/gcc-lib/i486-linuxlibc5/2.7.2.2/include -b i486-linuxlibc5
  640.         LDFLAGS = -b i486-linuxlibc5
  641.  
  642.   If you are using a configure script, define the $CFLAGS and $LDFLAGS
  643.   shell variables (by using env/setenv for csh/tcsh, or set/export for
  644.   sh/bash/etc) before running configure.  The makefiles generated by
  645.   this should contain the proper $CFLAGS and $LDFLAGS.  Not all config¡
  646.   ure scripts will pick up the variables, so you should check after run¡
  647.   ning configure and edit the makefiles by hand if necessary.
  648.  
  649.   If the programs you are compiling only call gcc (and not cpp or
  650.   binutils directly), you can use the following script to save having to
  651.   specify all of the options each time:
  652.  
  653.         #!/bin/bash
  654.         /usr/bin/gcc -b i486-linuxlibc5 -nostdinc \
  655.                      -I/usr/i486-linuxlibc5/include \
  656.                      -I/usr/lib/gcc-lib/i486-linuxlibc5/2.7.2.2/include "$@"
  657.  
  658.   You can then use this script instead of "gcc" when compiling.
  659.  
  660.   7.  Compiling C++ programs.
  661.  
  662.   Libg++ uses parts of the math library, so is link to libm.  Since your
  663.   existing libg++ will be compiled with your old library, you will have
  664.   to recompile libg++ with glibc or get a binary copy.  The latest
  665.   source for libg++ along with a binary linked with glibc (for x86) can
  666.   be found at <ftp://ftp.yggdrasil.com/private/hjl/>.
  667.  
  668.   7.1.  Installing libg++ for a test glibc install.
  669.  
  670.   If you have installed glibc as a test library, you need to install the
  671.   files into the directory you installed glibc into (such as
  672.   /usr/i486-linuxglibc2 for the example in the previous sections).  If
  673.   you are installing from the binary package (which i would recommend,
  674.   since i never had any luck compiling libg++ this way), you need to
  675.   extract the files into a temporary directory and move all the usr/lib/
  676.   files into the <install directory>/lib/ directory, the usr/include/
  677.   files into the <install directory>/include/ directory (remember to
  678.   delete your include/g++ link first!), and the usr/bin/ files into the
  679.   <install directory>/bin/ directory.
  680.  
  681.   7.2.  Installing libg++ for a primary glibc install.
  682.  
  683.   If you have installed glibc as the primary library, you first need to
  684.   move your old libg++ files into your old libc directory if you still
  685.   want to be able to compile g++ programs with your old libc.  Probably
  686.   the easiest way to do this is by installing a new copy of the libg++
  687.   compiled with libc 5 as in the previous section, and then installing
  688.   the glibc version normally.
  689.  
  690.   7.3.  Compiling C++ programs with the non-primary libc.
  691.  
  692.   If you are trying to compile a C++ program with a non-primary libc,
  693.   you will need to include the g++ include dir, which in the examples
  694.   above would be /usr/i486-linuxglibc2/include/g++ for a test glibc
  695.   install or /usr/i486-linuxlibc5/include/g++ for a primary glibc
  696.   install.  This can usually be done by appending the $CXXFLAGS
  697.   variable:
  698.  
  699.         CXXFLAGS = -nostdinc -I/usr/i486-linuxglibc2/include -I/usr/lib/gcc-lib/i486-linuxglibc2/2.7.2.2/include -I/usr/i486-linuxlibc5/include/g++ -b i486-linuxglibc2
  700.  
  701.   8.  Reporting bugs.
  702.  
  703.   If you think the lib is buggy, please read first the FAQ. It might be
  704.   that others had the same problem and there's an easy solution. You
  705.   should also check the section "Recommended Tools to Install the GNU C
  706.   Library" in the INSTALL file since some bugs are bugs of the tools and
  707.   not of glibc.
  708.  
  709.   Once you've found a bug, make sure it's really a bug. A good way to do
  710.   this is to see if the GNU C library behaves the same way some other C
  711.   library does. If so, probably you are wrong and the libraries are
  712.   right (but not necessarily). If not, one of the libraries is probably
  713.   wrong.
  714.  
  715.   Next, go to  <http://www-gnats.gnu.org:8080/cgi-bin/wwwgnats.pl>, and
  716.   look through the bug database.  Check here to verify the problem has
  717.   not already be reported. You should also look at the file BUGS
  718.   (distributed with libc) to check for known bugs.
  719.  
  720.   Once you're sure you've found a new bug, try to narrow it down to the
  721.   smallest test case that reproduces the problem. In the case of a C
  722.   library, you really only need to narrow it down to one library
  723.   function call, if possible.  This should not be too difficult.
  724.   The final step when you have a simple test case is to report the bug.
  725.   When reporting a bug, send your test case, the results you got, the
  726.   results you expected, what you think the problem might be (if you've
  727.   thought of anything), your system type, the versions of the GNU C
  728.   library, the GNU CC compiler, and the GNU Binutils which you are
  729.   using.  Also include the files config.status and config.make which are
  730.   created by running configure; they will be in whatever directory was
  731.   current when you ran configure.
  732.  
  733.   All bug reports for the GNU C library should be sent using the
  734.   glibcbug shell script which comes with the GNU libc to <bugs@gnu.org>
  735.   (the older address  <bugs@gnu.ai.mit.edu> is still working), or
  736.   submitted through the GNATS web interface at <http://www-
  737.   gnats.gnu.org:8080/cgi-bin/wwwgnats.pl>.
  738.  
  739.   Suggestions and questions should be sent to the mailing list at <bugs-
  740.   glibc@prep.ai.mit.edu>.  If you don't read the gnewsgroup
  741.   gnu.bug.glibc, you can subscribe to the list by asking  <bug-glibc-
  742.   request@prep.ai.mit.edu>.
  743.  
  744.   Please DO NOT send bug report for the GNU C library to <bug-
  745.   gcc@prep.ai.mit.edu>.  That list is for bug reports for GNU CC.  GNU
  746.   CC and the GNU C library are separate entities maintained by separate
  747.   people.
  748.  
  749.   9.  Sample specs file.
  750.  
  751.   Included here is a sample specs file for glibc 2 which is used by gcc
  752.   for compiling and linking.  It should be found in the directory
  753.   /usr/lib/gcc-lib/<new system dir>/<gcc version>.  If you are running
  754.   an x86 system, you probably can copy this section to the file exactly.
  755.  
  756.    *asm:
  757.    %{V} %{v:%{!V:-V}} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*}
  758.  
  759.    *asm_final:
  760.    %{pipe:-}
  761.  
  762.    *cpp:
  763.    %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!m386:-D__i486__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}
  764.  
  765.    *cc1:
  766.    %{profile:-p}
  767.  
  768.    *cc1plus:
  769.  
  770.    *endfile:
  771.    %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s
  772.  
  773.    *link:
  774.    -m elf_i386 %{shared:-shared}   %{!shared:     %{!ibcs:       %{!static:       %{rdynamic:-export-dynamic}     %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}}  %{static:-static}}}
  775.  
  776.    *lib:
  777.    %{!shared: %{pthread:-lpthread}        %{profile:-lc_p} %{!profile: -lc}}
  778.  
  779.    *libgcc:
  780.    -lgcc
  781.  
  782.    *startfile:
  783.    %{!shared:      %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s}                  %{!p:%{profile:gcrt1.o%s}                         %{!profile:crt1.o%s}}}}    crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}
  784.  
  785.    *switches_need_spaces:
  786.  
  787.    *signed_char:
  788.    %{funsigned-char:-D__CHAR_UNSIGNED__}
  789.  
  790.    *predefines:
  791.    -D__ELF__ -Dunix -Di386 -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(i386) -Amachine(i386)
  792.  
  793.    *cross_compile:
  794.    0
  795.  
  796.    *multilib:
  797.    . ;
  798.  
  799.   10.  Miscellanea.
  800.  
  801.   10.1.  Further information.
  802.  
  803.   10.1.1.  Web pages.
  804.  
  805.   ╖  FSF's GNU C Library Home Page
  806.      <http://www.gnu.org/software/libc/libc.html>
  807.  
  808.   ╖  Using GNU Libc 2 with Linux <http://www.imaxx.net/~thrytis/glibc/>
  809.  
  810.   ╖  Installing glibc-2 on Linux <http://huizen.dds.nl/~frodol/glibc/>.
  811.  
  812.   ╖  Debian libc5 to libc6 Mini-HOWTO
  813.      <http://www.gate.net/~storm/FAQ/libc5-libc6-Mini-HOWTO.html>.
  814.  
  815.   10.1.2.  Newgroups.
  816.  
  817.   ╖  comp.os.linux.development.system
  818.  
  819.   ╖  comp.os.linux.development.apps
  820.  
  821.   ╖  linux.dev.kernel
  822.  
  823.   ╖  gnu.bugs.glibc
  824.  
  825.   10.1.3.  Mailing lists.
  826.  
  827.      Glibc 2 Linux discussion list.
  828.         This list is intended for discussion among Linux users who have
  829.         installed glibc2, the new GNU C libraries.  Topics might include
  830.         compatibility issues and questions about the compilation of code
  831.         in a Linux/glibc setting.  To subscribe, send mail to
  832.         Majordomo@ricardo.ecn.wfu.edu
  833.         <mailto:Majordomo@ricardo.ecn.wfu.edu> with a body of "subscribe
  834.         glibc-linux <your email address>.
  835.  
  836.   10.2.  Credits.
  837.  
  838.   Most of this information was stolen from the GNU Libc web page
  839.   <http://www.gnu.org/software/libc/libc.html> and from Ulrich Drepper's
  840.   <drepper@gnu.ai.mit.edu> glibc 2 announcement and his comments.
  841.   Andreas Jaeger <aj@arthur.rhein-neckar.de> provided some of the
  842.   Reporting bugs section.
  843.  
  844.   The following people have provided information and feedback for this
  845.   document:
  846.  
  847.   ╖  Allex <allex@ms2.accmail.com.tw>
  848.  
  849.   ╖  Mark Brown <M.A.Brown-4@sms.ed.ac.uk>
  850.  
  851.   ╖  Ulrich Drepper <drepper@gnu.ai.mit.edu>
  852.  
  853.   ╖  Scott K. Ellis <ellis@valueweb.net>
  854.  
  855.   ╖  Aron Griffis <agriffis@coat.com>
  856.  
  857.   ╖  Andreas Jaeger <aj@arthur.rhein-neckar.de>
  858.  
  859.   ╖  Frodo Looijaard <frodol@dds.nl>
  860.  
  861.   ╖  Ryan McGuire <rmcguire@freenet.columbus.oh.us>
  862.  
  863.   ╖  Shaya Potter <spotter@capaccess.org>
  864.  
  865.   ╖  Les Schaffer <godzilla@futuris.net>
  866.  
  867.   ╖  Andy Sewell <puck@pookhill.demon.co.uk>
  868.  
  869.   ╖  Gary Shea <shea@gtsdesign.com>
  870.  
  871.   ╖  Stephane <sr@adb.fr>
  872.  
  873.   ╖  Jan Vandenbos <jan@imaxx.net>
  874.  
  875.   Translations of this document are being done by:
  876.  
  877.   ╖  Chinese: Allex <allex@ms2.accmail.com.tw>
  878.  
  879.   ╖  French:  Olivier Tharan <tharan@int-evry.fr>
  880.  
  881.   ╖  Japanese:  Kazuyuki Okamoto <ikko-@pacific.rim.or.jp>
  882.  
  883.   10.3.  Feedback.
  884.  
  885.   Besides writing this HOWTO, maintaining the glibc 2 for Linux
  886.   <http://www.imaxx.net/~thrytis/glibc> page, and using it on my
  887.   machine, I have nothing to do with the glibc project.  I am far from
  888.   knowledgeable on this topic, though I try to help with problems mailed
  889.   to me.  I welcome any feedback, corrections, or suggestions you have
  890.   to offer.  Please send them to thrytis@imaxx.net
  891.   <mailto:thrytis@imaxx.net>.
  892.  
  893.   10.4.  Copyright.
  894.  
  895.   Copyright (c) 1997 by Eric Green.  This document may be distributed
  896.   under the terms set forth in the LDP license.
  897.  
  898.